Repository navigation
sensor: imx662 on hi3516cv6xx is the module's own vendor driver - #296
Conversation
The IMX662 driver added in #282 had no IMX662 tuning: its ISP tables, AWB calibration and colour matrix were seeds borrowed from smart_sc450ai, and its README said so. This replaces it with the driver of the SIP-K662C6S module's stock firmware (xipc, sensor type 272), recovered from that firmware and rebuilt against this tree's sensor interface and common/sensor_common.c: - the power-on register tables for 1080p30 and 1080p60 RAW12 and 1080p90 RAW10; - the vendor's exposure and gain model: one 0.3 dB table for analog and sensor digital gain, high conversion gain above analog index 99; - its ISP default tables, AWB calibration and colour matrix, each a byte image of its B051 structure, guarded by a _Static_assert so a structure that stops matching refuses to compile. The vendor driver has no mirror/flip; the previous one did. It is added: HREVERSE/VREVERSE, kept per pipe, written by the callback and again by every bring-up in standby, both under cis->mutex. On the module at night, with majestic and the same IQ profile: - AE settled at the same exposure and gain with both drivers (50 ms, about 37x, isp_avelum 42-43). A street at night stays in colour with this driver where the previous one gave an almost grey picture, at the cost of a slightly softer image. - All four orientations come out right, set live (majestic logs "Live image orientation (sensor)") and from a restart. R/G and B/G stay within 0.04 of the upright picture, so the Bayer phase does not move. Neither driver reads registers back (cis_read_reg is a stub tree-wide), and the previous driver's 100 fps mode was declared but refused at the 37.125 MHz sensor clock, so neither is lost.
PR Summary by QodoReplace IMX662 scaffold with SIP-K662C6S vendor driver
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo
1.
|
The vendor built its NR default against an SDK whose ot_isp_nr_attr has no load_ref_en or snr_version, so its bytes from 152 on are B051's from 160 on. Taken as it was, the ISP held an NR default with both fields 0x006C006C (two coarse strengths) and every later field 8 bytes off, and ot_mpi_isp_get_nr_attr refused it: majestic logged "IQ: reading the chip for [static_nr] failed: ERR_ISP_0x47" with this driver and not with the one it replaced. Re-laid with both fields 0 and the 8 bytes read past the vendor's table dropped; [static_nr] now applies. The other 16 tables decode against B051 with every enum and switch in range. From review: - The bring-up replays the AE register slots before AE has filled them, and global init left VMAX at 0 and SHR0 below its minimum. The unset ones are seeded with the mode's frame length and the shortest exposure; what AE already wrote is left alone. - An exposure as long as the frame is the longest SHR0 allows, not an unsigned wrap that landed on the shortest. - The RAW12 tables write the 12-bit AD timing (0x3A50-52, the sensor's own defaults), so a switch back from the 90 fps RAW10 mode does not keep the 10-bit form. - A failed register write fails the bring-up, which then is not marked initialised. - The I2C descriptor is opened and closed under the sensor lock, which the orientation callback holds while it uses it. On the module: bring-up at 30 fps, live flip, a pipeline rebuild, and [static_nr] applied, with the picture as before.
|
Addressed in 3e2664e:
While testing these on the module, a seventh problem showed up. The vendor's Bayer NR default table is laid out for an SDK without |
…ets and upstream STARVIS 2 (#301) * sensor: imx675 for hi3516cv6xx, its bring-up from the K662C6S firmware An IMX675 (STARVIS 2, 5 MP) driver on the cv6xx cis framework. The SIP-K662C6S module's stock firmware has no MPP driver for it, only the register bring-up, inlined (sub_AB358 for 5M, sub_ABB80 for 4M). Those tables are taken as they stand. The register map, exposure and gain model, AWB and ISP tables come from sony_imx664, the nearest STARVIS 2 sibling the firmware carries, and are untuned for the IMX675. - 2592x1944 and 2592x1520 (an even, centred crop), 30 fps RAW10, 4 lanes at 594 Mbps, 37.125 MHz; VMAX 2200, HMAX 1125. - Mirror and flip on HREVERSE/VREVERSE, kept per pipe, written in standby by every bring-up and live by the callback. - The imx662 hardening: sensor lock around bring-up, SHR0 underflow guard, VMAX/SHR0 seeded before AE, checked bring-up, _Static_assert on each ISP byte image, and the Bayer NR re-lay of #296. Checked against Sony's IMX675 Standard Register Setting Ver1.0 (column 4lane, 10bit, 594Mbps, 30fps) and the upstream Linux sony-starvis2 v7 series (OpenIPC/firmware#2736). Every register the sheet sets matches, except 25 analog values where the vendor table is an earlier revision: 0x3c0a-0x3c0f, 0x4550-0x4564 and 0x347b. Both references agree on those, so they follow Sony; each is marked with the vendor's value. LANEMODE is left at reset (4 lanes), where HMAX 1125 clears both references' shortest line. Not run on an IMX675 yet. * sensor: imx664 for hi3516cv6xx, from the K662C6S firmware The IMX664 (STARVIS 2, 4 MP) driver of the SIP-K662C6S module's stock firmware, recovered from that firmware and rebuilt against this tree's sensor interface and common/sensor_common.c, as sony_imx662 was in #296: its power-on table, exposure and gain model (0.3 dB ladder, high conversion gain above analog index 99), AWB calibration and ISP default tables. - 2688x1520 30 fps RAW12, 2 lanes at 1188 Mbps, 37.125 MHz. - Mirror and flip on HREVERSE/VREVERSE, per pipe, as sony_imx662. - The imx662 hardening, and the same Bayer NR re-lay: the vendor's NR image is byte-identical to imx662's. The table is the vendor's, byte for byte. Neither Sony's IMX662 sheet nor the upstream STARVIS 2 driver covers the IMX664, so it has no register oracle. Its ADBIT (0x3022) value 2 is not one the sibling sheets define; it is kept and noted. Not run on an IMX664 yet. * sensor: imx678 for hi3516cv6xx, checked against the upstream STARVIS 2 driver The K662C6S firmware has only scene tuning for the IMX678 (STARVIS 2, 8 MP), no driver. This one starts from Sony's Hi3519DV500 driver, a self-contained driver with its own I2C layer, and is rewritten onto the cv6xx cis framework with sony_imx662's structure and hardening. - One mode: 3840x2160 30 fps RAW12, 4 lanes at 1188 Mbps, 37.125 MHz; VMAX 2250, HMAX 1100. The source's 60 fps mode is dropped: its init only ever wrote the 4K30 table. - The init table is the source's, with SHR0 seeded at 4 (Sony's minimum, not 3). It also adds the 13 registers the upstream Linux sony-starvis2 v7 table sets and the source did not. Against that table there are no value mismatches over its ~370 registers (OpenIPC/firmware#2736). - Gain: the IMX678's own 27-step HCG offset, switched above analog index 99. The source switched at 27, which would write gain codes below 34 under HCG, and Sony's reference forbids those. - The IMX678's own AWB, colour matrix and DNG colour. Its Bayer NR, DRC, LSC and ACS are imx664 byte images, and its CA is sc450ai's; each is a _Static_assert-guarded b[N]. Mesh shading off, as the vendor ships every CV610 sensor. The sharpen fields CV610 has and the Hi3519DV500 lacks are filled from imx664. - Mirror and flip on HREVERSE/VREVERSE; RGGB in every orientation, as upstream. Not run on an IMX678 yet, and 4K30 throughput on CV610 is unmeasured. * sensor: imx415 for hi3516cv6xx, from the K662C6S firmware The K662C6S board's default sensor, the IMX415 (original STARVIS, 8 MP). The bring-up is the stock firmware's (sub_A9278 8M, sub_A9A8C 2M binning). The gen-1 exposure and gain model (no conversion gain) and the AWB come from the Hi3516CV500 driver, and the ISP tables are the firmware's IMX335 tables, untuned for the IMX415. - 3840x2160 and 1920x1080 2x2 binning, 30 fps RAW10, 4 lanes at 891 Mbps, 37.125 MHz; VMAX 2250, HMAX 1100. - The CFA is GBRG, as the CV500 driver, mainline Linux (SGBRG10) and the OpenIPC CV500 profile have it; the extraction had carried RGGB over from its IMX335 template. - Mirror and flip on 0x3030. The inverted readout starts one pixel further in, so the Bayer phase stays put. - The imx662 hardening and Bayer NR re-lay; mesh shading off, since the IMX335 grid fits no IMX415 mode (#299). Checked against mainline drivers/media/i2c/imx415.c (its init table, the 891 Mbps link table and the 37.125 MHz clock parameters): no value mismatches. HMAX 1100 is the 4-lane shortest line at that rate. 0x30c0/0x30c1 (sync pin outputs) stay at reset, high impedance, as the vendor runs them. Not run on an IMX415 yet. * sensor: sc850sl for hi3516cv6xx, from the K662C6S firmware The SmartSens SC850SL (8 MP) driver of the SIP-K662C6S stock firmware, which has no SDK counterpart. Its init is unrolled in the firmware, not a table, and was recovered write by write. Its ISP default tables come byte for byte from the firmware's callback set (sub_B4538); the gain tables are SmartSens-standard and were checked against the binary. Laid out as smart_sc450ai. - 27 MHz sensor clock ("27MInput_4lane_1080Mbps_12bit"). - Both Bayer NR images had the #296 layout skew and are re-laid. - Hardening as sony_imx662. Standby and restart drive 0x0100; the vendor's were empty. - Mirror and flip on 0x3221, relative to the 0x66 the init writes (the module is mounted rotated). BGGR in every orientation, as the XMedia SC850SL driver reports it. Not run on an SC850SL yet. * sensor: gc2063 for hi3516cv6xx, from the K662C6S firmware The GalaxyCore GC2063 (2 MP, GC2053 register-compatible), laid out as galaxycore_gc4653. The init is the stock firmware's (sub_AE770), and it is write for write the Hi3516CV500 GC2053 1080p30 sequence. The exposure and gain model and the AWB come from that driver. The ISP tables are gc4023's, untuned for the GC2063. - 1920x1080 30 fps RAW10, 27 MHz ("gc2063 27Mclk 2M30fps(MIPI)"). - AE as the GC2053 drivers and gc4653 sync it: shutter and gain one frame after VMAX. - RGGB, the order the OpenIPC GC2053 profiles run this same table with. - Mirror and flip on page-0 0x17. The GC2053 references move no window for it. Not verified on a GC2063. - Hardening as sony_imx662. Standby and restart use 0xf2/0xfc, as the CV500 driver does. Not run on a GC2063 yet. * sensor: imx662 holds SHR0 at Sony's minimum of 4 Sony's IMX662 register setting sheet and the upstream Linux STARVIS 2 driver (since v7's exposure fix) put SHR0 in [4, VMAX - 1]. The driver clamped it at 3, and it told AE that VMAX - 2 lines was the longest exposure, which that clamp never allowed. Both are now 4. The longest exposure is one line shorter, and AE is told exactly what it gets. Found while checking the cv6xx STARVIS 2 drivers against those references (OpenIPC/firmware#2736). * sys_config: hi3516cv6xx clocks for gc2063, sc850sl, imx415, imx664, imx675, imx678 GC2063 and SC850SL run at 27 MHz, as their vendor banners say. The four Sony sensors run at 37.125 MHz, as INCK_SEL in each init table says. Without an entry, the sensor clock is written 0 and the sensor stays dark. * README: list the hi3516cv6xx sensors Adds the six drivers above, and GC4653, MIS20S1, CV2003 and VS4388, which had drivers but no rows. * sensor: review round on the recovered hi3516cv6xx drivers - sc850sl: the bring-up seeded only the linear-mode slots, so a 2-to-1 WDR bring-up replayed zero long and short exposure, gains and short-exposure limit over the WDR table. Each is now seeded from the WDR table's own values (long 0x1000, short 0x100, limit 0x10a, 1x gain), and only where AE has not written yet. - sc850sl: the pixel-calibration hooks wrote VMAX low byte first to 0x320e, its high byte, and the exposure as plain bytes. On leaving they wrote back fl_std, which is in half lines. They now write VMAX high byte first and the exposure in half lines with the 4/8/4 split cmos_inttime_update_linear() uses, and leave with fl_std >> 1. - imx675, imx664, imx415: AE was told the longest exposure was VMAX - 2 (VMAX - 8 on the IMX415), but SHR0 stays at 6 (9) or above, so the longest is VMAX - 6 (VMAX - 9). FL_OFFSET_LINEAR now equals SHR0_MIN, and AE is told what it gets. - gc2063: the analog-gain ceiling stays at 113168, below the table's last entry, as the Hi3516CV500 GC2053 driver has it; now said beside the define.
The IMX662 driver added in #282 had no IMX662 tuning: its ISP tables, AWB
calibration and colour matrix were seeds borrowed from smart_sc450ai, and
its README said so. This replaces it with the driver of the SIP-K662C6S
module's stock firmware (xipc, sensor type 272), recovered from that
firmware and rebuilt against this tree's sensor interface and
common/sensor_common.c:
RAW10;
sensor digital gain, high conversion gain above analog index 99;
image of its B051 structure, guarded by a _Static_assert so a structure
that stops matching refuses to compile.
The vendor driver has no mirror/flip; the previous one did. It is added:
HREVERSE/VREVERSE, kept per pipe, written by the callback and again by every
bring-up in standby, both under cis->mutex.
On the module at night, with majestic and the same IQ profile:
37x, isp_avelum 42-43). A street at night stays in colour with this
driver where the previous one gave an almost grey picture, at the cost of
a slightly softer image.
orientation (sensor)") and from a restart. R/G and B/G stay within 0.04 of
the upright picture, so the Bayer phase does not move.
Neither driver reads registers back (cis_read_reg is a stub tree-wide), and
the previous driver's 100 fps mode was declared but refused at the 37.125
MHz sensor clock, so neither is lost.